package me.zhengjie.modules.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;

/**
 * 场景风险信息表
 *
 * @author wj
 * @version 1.0.0
 * @since 1.0.0
 */
@Entity
@Getter
@Setter
@Table(name = "st_safe_risk_item")
public class SafeRiskItem extends BaseEntity implements Serializable {

    @Id
    @NotNull(groups = Update.class)
    @ApiModelProperty(value = "ID", hidden = true)
    @GeneratedValue(generator = "item_id")
    @GenericGenerator(name = "item_id", strategy = "uuid")
    @Column(name = "id", length = 32, unique = true, nullable = false)
    private String id;

    @NotNull
    @ManyToOne
    @JoinColumn(name = "type_id", referencedColumnName = "id")
    @ApiModelProperty(value = "场景风险类型id")
    private SafeRiskType safeRiskType;

    @NotBlank
    @ApiModelProperty(value = "场景类型0:业务 1:功能")
    private String sceneType;

    @ExcelProperty("业务类别")
    @ApiModelProperty(value = "业务类别")
    private String businessType;

    @ExcelProperty("场景类别")
    @ApiModelProperty(value = "场景类别")
    private String envType;

    @ExcelProperty("应用场景")
    @ApiModelProperty(value = "应用场景")
    private String appEnv;

    @ExcelProperty("风险项")
    @ApiModelProperty(value = "风险项")
    private String risk;

    @ExcelProperty("检查点")
    @ApiModelProperty(value = "检查点")
    private String point;

    @ExcelProperty("案例编号")
    @ApiModelProperty(value = "案例编号")
    private String caseId;

    @ExcelProperty("案例名称")
    @ApiModelProperty(value = "案例名称")
    private String caseName;

    @ExcelProperty("测试方法")
    @ApiModelProperty(value = "测试方法")
    private String testMethod;

    @ExcelProperty("适用范围")
    @ApiModelProperty(value = "适用范围")
    private String scope;

    @ExcelProperty("风险等级")
    @ApiModelProperty(value = "风险等级")
    private String riskLevel;

    @ExcelProperty("适用类型")
    @ApiModelProperty(value = "适用类型")
    private String applyType;

    @ExcelProperty("对应关系")
    @ApiModelProperty(value = "对应关系")
    private String correspondence;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SafeRiskItem that = (SafeRiskItem) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(safeRiskType, that.safeRiskType) &&
                Objects.equals(sceneType, that.sceneType) &&
                Objects.equals(businessType, that.businessType) &&
                Objects.equals(envType, that.envType) &&
                Objects.equals(appEnv, that.appEnv) &&
                Objects.equals(risk, that.risk) &&
                Objects.equals(point, that.point) &&
                Objects.equals(caseId, that.caseId) &&
                Objects.equals(caseName, that.caseName) &&
                Objects.equals(testMethod, that.testMethod) &&
                Objects.equals(scope, that.scope) &&
                Objects.equals(riskLevel, that.riskLevel) &&
                Objects.equals(applyType, that.applyType) &&
                Objects.equals(correspondence, that.correspondence);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, safeRiskType, sceneType, businessType, envType, appEnv, risk, point, caseId, caseName, testMethod, scope, riskLevel, applyType, correspondence);
    }
}
